<?php
/**
 * Muestra los productos del catálogo, en su versión reducida, por categorías
 *
 * Utiliza las variables de entrono:
 * $_GET["current_"]
 *
*/
# User session management
require('includes/user_manage.php');
//Objetos y funciones de las categorías
 require_once('includes/classes/category.php');

	#We load the subcategories of the selected category
	$my_catalog=new category();
	$my_catalog->id=$_GET["category_id"];
	$my_catalog->db_load_subcategories();
	$serCategories=json_encode($my_catalog);
	if ($user->isAdmin) { 
		include($server->get_path_name('flap_tp_admin.php'));
	}
	else {
		include($server->get_path_name('flap_tp.php'));
	}

//This part is for printing the categories for bots that can't implement javascript
if (isset($_SERVER['HTTP_USER_AGENT']) && $server->bot_detect($_SERVER['HTTP_USER_AGENT'])) {
	foreach ($my_catalog->categories as $sub_category) {
?>
    <table class="flap">
	<tr>
	    <td class="tl"></td>
	    <td class="t"></td>
	    <td class="tr"></td>
	</tr>
	<tr>
	    <td class="ml"></td>
	    <td class="m">
		<a href="?section=shop_content&category_id=<?php echo $sub_category->id ?>" myFor="rightContentBox:containerProducts"><?php echo $sub_category->name ?></a>
	    </td>
	    <td class="mr"></td>
	</tr>
    </table>
<?php
	}
}
?>
<script type="text/javascript">
	var categoryId=null;
	var catalogPointer=myCatalog;
	catalogPointer=catalogPointer.moveToChildren("selected");
	catalogPointer.loadCategories('<?php echo $serCategories; ?>');
	catalogPointer.loadCategoriesListView("flaps");
	catalogPointer.refreshCategoriesListView("flaps");
	if (catalogPointer.children[0]) {
		catalogPointer=catalogPointer.children[0];
		catalogPointer.myCategory.myActivate();
		catalogPointer.myCategory.myActionButton.request();
	}
	else {
		var shopContentHref="?section=shop_content&category_id=" + catalogPointer.myCategory.id;
		setViewTo( shopContentHref ,'rightContentBox:containerProducts');
	}
</script>